package com.example.vote;

import com.example.vote.controller.LocalDateConvertor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.time.LocalDate;

@SpringBootApplication
@MapperScan("com.example.vote.mapper")
public class VoteApplication implements WebMvcConfigurer {

    public static void main(String[] args) {
        SpringApplication.run(VoteApplication.class, args);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/**")
//                .addResourceLocations("file:/root/ly/yc133/vote/src/main/resources/static/");
        registry.addResourceHandler("/**")
                .addResourceLocations("file:F:\\_文件柜\\133\\组员(李四)\\yc-133\\vote\\src\\main\\resources\\static/");
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        // 内置的转换器无法移除
        registry.removeConvertible(String.class, LocalDate.class);
        registry.addConverter(new LocalDateConvertor());
    }
}
